﻿<?xml version="1.0" encoding="utf-8" ?>
<CodeSnippets  xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
    <CodeSnippet Format="1.0.0">
        <Header>
            <Description>扩展的可空的引用实体属性</Description>
            <Title>Rafy Reference Property Extension NullableNullable</Title>
            <Shortcut>RafyPropertyExtensionReferenceNullable</Shortcut>
            <Author>HuQingfang</Author>
            <SnippetTypes>
                <SnippetType>Expansion</SnippetType>
            </SnippetTypes>
        </Header>
        <Snippet>
            <Declarations>
                <Literal>
                    <ID>RefEntityType</ID>
                    <ToolTip>引用实体类型</ToolTip>
                    <Default>RefEntity</Default>
                </Literal>
                <Literal>
                    <ID>RefPropertyName</ID>
                    <ToolTip>引用实体属性名</ToolTip>
                    <Default>RefPropertyName</Default>
                </Literal>
                <Literal>
                    <ID>Comment</ID>
                    <Default>属性注释</Default>
                </Literal>
                <Literal>
                    <ID>ReferenceType</ID>
                    <ToolTip>引用类型（是否为组合父引用）</ToolTip>
                    <Default>Normal</Default>
                </Literal>
                <Literal>
                    <ID>KeyType</ID>
                    <ToolTip>引用实体的标识类型。</ToolTip>
                    <Default>long</Default>
                </Literal>
                <Literal>
                    <ID>ClassName</ID>
                    <Default>SomeEntity</Default>
                </Literal>
                <Literal Editable="false">
                    <ID>DeclareType</ID>
                    <Function>ClassName()</Function>
                </Literal>
            </Declarations>
            <Code Language="csharp">
                <![CDATA[#region $RefEntityType$ $RefPropertyName$ ($Comment$)
                
        /// <summary>
        /// $Comment$ 扩展属性。
        /// </summary>
        public static readonly IRefIdProperty $RefPropertyName$IdProperty =
            P<$ClassName$>.RegisterRefIdExtension<$KeyType$>("$RefPropertyName$Id", typeof($DeclareType$), true);
        /// <summary>
        /// 获取 $Comment$ 属性的值。
        /// </summary>
        /// <param name="me">要获取扩展属性值的对象。</param>
        public static $KeyType$? Get$RefPropertyName$Id(this $ClassName$ me)
        {
            return ($KeyType$?)me.GetRefNullableId($RefPropertyName$IdProperty);
        }
        /// <summary>
        /// 设置 $Comment$ 属性的值。
        /// </summary>
        /// <param name="me">要设置扩展属性值的对象。</param>
        public static void Set$RefPropertyName$Id(this $ClassName$ me, $KeyType$? value)
        {
            me.SetRefNullableId($RefPropertyName$IdProperty, value);
        }
        
        public static readonly RefEntityProperty<$RefEntityType$> $RefPropertyName$Property =
            P<$ClassName$>.RegisterRefExtension<$RefEntityType$>("$RefPropertyName$", typeof($DeclareType$), $RefPropertyName$IdProperty);
        /// <summary>
        /// 获取 $Comment$ 属性的值。
        /// </summary>
        /// <param name="me">要获取扩展属性值的对象。</param>
        public static $RefEntityType$ Get$RefPropertyName$(this $ClassName$ me)
        {
            return me.GetRefEntity($RefPropertyName$Property);
        }
        /// <summary>
        /// 设置 $Comment$ 属性的值。
        /// </summary>
        /// <param name="me">要设置扩展属性值的对象。</param>
        public static void Set$RefPropertyName$(this $ClassName$ me, $RefEntityType$ value)
        {
            me.SetRefEntity($RefPropertyName$Property, value);
        }

        #endregion$end$]]>
            </Code>
        </Snippet>
    </CodeSnippet>
</CodeSnippets>